﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Common.Security
{
    public static class Authorization
    {
        const string authorizationType = "SEG.Authorization, SEG.Common";
        static IAuthorization _authorizationInstance;
        private static IAuthorization AuthorizationInstance
        {
            get
            {
                if (_authorizationInstance == null)
                {
                    var authType = Type.GetType(authorizationType);

                    _authorizationInstance = authType.GetConstructor(Type.EmptyTypes).Invoke(null) as IAuthorization;

                }
                return _authorizationInstance;
            }
        }

        public static Boolean CanExecute(string formulario)
        {
            return AuthorizationInstance.CanExecute(formulario);
        }

        public static Boolean CanExecuteAdd(string formulario)
        {
            return AuthorizationInstance.CanExecuteAdd(formulario);
        }
        public static Boolean CanExecuteModify(string formulario)
        {
            return AuthorizationInstance.CanExecuteModify(formulario);
        }
        public static Boolean CanExecuteDelete(string formulario)
        {
            return AuthorizationInstance.CanExecuteDelete(formulario);
        }
        public static Boolean CanExecuteView(string formulario)
        {
            return AuthorizationInstance.CanExecuteView(formulario);
        }

        public static Boolean CanExecuteExport(string formulario)
        {
            return AuthorizationInstance.CanExecuteExport(formulario);
        }
        public static Boolean CanExecutePrint(string formulario)
        {
            return AuthorizationInstance.CanExecutePrint(formulario);
        }
    }

    public interface IAuthorization
    {
        Boolean CanExecuteAdd(string formulario);
        Boolean CanExecuteModify(string formulario);
        Boolean CanExecuteDelete(string formulario);
        Boolean CanExecuteView(string formulario);
        Boolean CanExecute(string formulario);

        Boolean CanExecuteExport(string formulario);
        Boolean CanExecutePrint(string formulario);
    }
}
